#include <iostream>
using namespace std;

int n;
string s;

int fun()
{
    bool flag = false;
    for (int i = 1; i < n; i++)
    {
        if (s[i] != s[0])
        {
            flag = true;
        }
    }
    if (flag == false) return 0;
    flag = true;
    int left = 0, right = n - 1;
    while (left < right)
    {
        if (s[left] == s[right])
        {
            left++;
            right--;
        }
        else
        {
            flag = false;
            break;
        }
    }
    if (flag) return n - 1;
    else return n;
}
int main()
{
    cin >> s;
    n = s.size();

    cout << fun() << endl;
    return 0;
}